(function(){
	var _head = document.getElementsByTagName("head")[0],_script = document.createElement("script");
	_script.type = "text/javascript";
	_script.src = "http://imgcache.qq.com/bossweb/unikf/js/md5.js";
	_head.appendChild(_script);
	var _id=$("#service_id").val() ;
	if( typeof serviceNameOfFaq==="undefined" || serviceNameOfFaq[_id]===undefined){
		$("#back_nav").find('.sign_next').hide();
		return ;
	}
	$("#nav_second").remove();
	var _name=serviceNameOfFaq[_id].name+"产品专区";
	var _link="http://kf.qq.com/product/"+serviceNameOfFaq[_id].serviceLink+".html";
	$("#back_nav").append("<a href='"+_link+"' class=''>"+_name+"</a>");
})();
function addCookie(objName, objValue, objHours){
    var str = objName + "=" + escape(objValue);
    str += ";domain=service.qq.com";
    if (objHours > 0) {
        var date = new Date();
        var ms = objHours * 3600 * 1000;
        date.setTime(date.getTime() + ms);
        str += ";expires=" + date.toGMTString();
    }
    document.cookie = str;
}

function getCookie(name){
    var search = name + "=",cookies = document.cookie.split(" ");
     for (var i = 0,l = cookies.length; i < l; i++) {
     	var pair = cookies[i].split(";")[0];
     	if (pair.indexOf(search) == 0) {
        	var offset = search.length;
            	var end = pair.length;
            	return pair.substring(offset, end);
        	}
	}
    return "";
}

function choise_check(qid){
    if (getRadioValue(qid) == 2) {
        document.getElementById("q1b").style.display = '';
        //判断是否有imc或者ics的连接
    }
    else {
        document.getElementById("q1b").style.display = 'none';
        document.getElementById("show_done3").style.display = 'none';
    }
    return true;
}
function submit_choise_check(qid){
    if (getRadioValue(qid) == 2) {
        document.getElementById("q1b").style.display = '';        
    }
    else {
        document.getElementById("q1b").style.display = 'none';
        document.getElementById("show_done3").style.display = 'none';
    }
    return true;
}
function do_close(){
    window.opener = null;
    window.close();
    return;
}

function getRadioValue(qname){
    var rs = document.getElementsByName(qname);
    for (var i = 0; i < rs.length; i++) {
        if (rs[i].checked) {
            return rs[i].value;
        }
    }
}

function setRadioValue(qname, cvalue){
    var rs = document.getElementsByName(qname);
    if (cvalue > rs.length) {
        return;
    }
    else {
        rs[cvalue - 1].checked = true;
    }
}

function IsSeleRadio(bname){
    var bn = document.getElementsByName(bname);
    var k = 0;
    var i;
    for (i = 0; i < bn.length; i++) {
        if (!bn[i].checked) {
            k++;
        }
    }
    if (k == bn.length) {
        return false;
    }
    else {
        return true;
    }
}

function checkInput(){
    if (!IsSeleRadio("q1")) {
        return false;
    }
    return true;
}

function do_submit(){
    if (false == checkInput()) {
        return false;
    }
    var c1 = getRadioValue("q1");
    var c2 = 0;
    if (c1 == 2) {
        c2 = document.getElementById("q1b").value;
    }
    if (c2 == 9999) {
        return true;
    }
    var faqid = document.getElementById("faqid").value;
    var sid = document.getElementById("sid").value;
    var cgi_url = "http://kf.qq.com/cgi-bin/ResearchSubmit?rand=" + Math.random();
    var params = "c1=" + c1 + "&c2=" + c2 + "&sys=3&faqid=" + faqid + "&sid=" + sid + "&tk="+hex_md5(getCookie("uin")+getCookie("skey"));
    var loder = new net.ContentLoader(cgi_url, research_submit_cb_jr, params);
    document.getElementById("show_question").style.display = 'none';
    var show_done2 = document.getElementById("show_done2");
    if (c1 == 2 && show_done2 != null) {
        show_done2.style.display = 'block';
        submit_choise_check('q1');
    }
    else 
        document.getElementById("show_done").style.display = 'block';
    return true;
}

function research_submit_cb_jr(){
    if (this.req.readyState == 4) {
        if (this.req.status == 200) {
            return;
        }
        else {
            alert("系统忙,请您稍候再试!");
        }
    }
}

function research_submit_cb(){
    if (this.req.readyState == 4) {
        if (this.req.status == 200) {
            var isFirefox = (navigator.userAgent.indexOf("Firefox") > 0);
            if (isFirefox) {
                var rText = this.req.responseText;
                var xml_doc = new DOMParser().parseFromString(rText, "text/xml");
                var xml_msg = xml_doc.getElementsByTagName("MSG_ENTRY")[0];
                if (xml_msg != null) {
                    var sActionCode = xml_msg.childNodes[1].firstChild == null ? 0 : xml_msg.childNodes[1].firstChild.nodeValue;
                    var sErrCode = xml_msg.childNodes[2].firstChild == null ? 0 : xml_msg.childNodes[2].firstChild.nodeValue;
                    var sMsg = xml_msg.childNodes[3].firstChild == null ? "" : xml_msg.childNodes[3].firstChild.nodeValue;
                    var sToURL = xml_msg.childNodes[4].firstChild == null ? "" : xml_msg.childNodes[4].firstChild.nodeValue;
                    if (sActionCode == 0) {
                        parent.window.location.href = sToURL;
                    }
                    if (sActionCode == 1 && sToURL.length > 0) {
                        openLogin(sToURL);
                    }
                    if (sActionCode == 2 && sToURL.length > 0) {
                        parent.window.location.replace(sToURL);
                    }
                    if (sActionCode == 3) {
                        return true;
                    }
                }
            }
            else {
                var xml_doc = this.req.responseXML.documentElement;
                var xml_msg = xml_doc.getElementsByTagName("MSG_ENTRY")[0];
                if (xml_msg != null) {
                    var sActionCode = xml_msg.childNodes[0].firstChild == null ? 0 : xml_msg.childNodes[0].firstChild.nodeValue;
                    var sErrCode = xml_msg.childNodes[1].firstChild == null ? 0 : xml_msg.childNodes[1].firstChild.nodeValue;
                    var sMsg = xml_msg.childNodes[2].firstChild == null ? "" : xml_msg.childNodes[2].firstChild.nodeValue;
                    var sToURL = xml_msg.childNodes[3].firstChild == null ? "" : xml_msg.childNodes[3].firstChild.nodeValue;
                    if (sActionCode == 0) {
                        parent.window.location.href = sToURL;
                    }
                    if (sActionCode == 1 && sToURL.length > 0) {
                        openLogin(sToURL);
                    }
                    if (sActionCode == 2 && sToURL.length > 0) {
                        parent.window.location.replace(sToURL);
                    }
                    if (sActionCode == 3) {
                    }
                }
            }
        }
        else {
            alert("系统忙,请您稍候再试!");
        }
    }
}

function checkNum(KeyCode){
    if (((KeyCode > 47) && (KeyCode < 58)) || (KeyCode == 8) || (KeyCode == 46) || (KeyCode == 37) || (KeyCode == 39) || ((KeyCode > 95) && (KeyCode < 106)) || (KeyCode == 9)) {
        return true;
    }
    else {
        return false;
    }
}

function init_page(){
    var submitedlist = getCookie("research_submited");
    if (submitedlist == '') {
        return true;
    }
    var paras = submitedlist.split(">||<");
    for (i = 0; i < paras.length; ++i) {
        if (paras[i] == document.getElementById("faqid").value) {
            document.getElementById("show_question").style.display = 'none';
            return true;
        }
        else {
            document.getElementById("show_question").style.display = '';
        }
    }
}
function T(n){
	//document.getElementById("faq_content").style.fontSize=n+"px";
	document.getElementById("faq_content").className="faq_content font_"+n;
}
function addFaqFavorite(title,id){
	var isFirefox=(navigator.userAgent.indexOf("Firefox")>0);
	if (isFirefox)  // firefox
	{
  	window.sidebar.addPanel(title, "http://service.qq.com/info/"+id+".html","");
	}
	else if (document.all) 
	{
		window.external.addFavorite("http://service.qq.com/info/"+id+".html", title);
	}
}